﻿@using WB.Core.BoundedContexts.Headquarters.Services
@using WB.Core.Infrastructure.Versions
@using WB.Infrastructure.Native.Workspaces
@using WB.UI.Headquarters.Services
@inject IAuthorizedUser authorizedUser
@inject IProductVersion productVersion
@inject IWorkspaceContextAccessor workspaceAccessor

@{
    var workspace = workspaceAccessor.CurrentWorkspace();
    var isSystemWorkspace = workspace?.IsSystemDefinedWorkspace() ?? false;
}

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container-fluid ">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <a href="javascript:void(0);" class="active-page">  @(ViewBag.SpecificPageCaption ?? Html.ActivePage())</a>
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar top-menu"></span>
                <span class="icon-bar mid-menu"></span>
                <span class="icon-bar bottom-menu"></span>
            </button>
            <div class="navbar-brand">
                @if (isSystemWorkspace)
                {
                    <a class="logo" asp-action="Index" asp-controller="UsersManagement"></a>
                }
                else
                {
                    <a class="logo" asp-action="Index" asp-controller="Home"></a>
                }
            </div>
        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="navbar">
            <partial name="_WorkspaceSelector" />

            @if (authorizedUser.IsAdministrator 
                && (this.workspaceAccessor.CurrentWorkspace()?.IsSystemDefinedWorkspace() ?? false))
            {
                <partial name="ServerAdminMenu" />
            }
            else if (authorizedUser.IsAdministrator)
            {
                <partial name="AdminMainMenu" />
            }
            else if (authorizedUser.IsHeadquarter)
            {
                @if (this.workspaceAccessor.CurrentWorkspace()?.IsSystemDefinedWorkspace() ?? false)
                {
                    <partial name="UsersHeadquartersMainMenu" />
                }
                else
                {
                    <partial name="HeadquartersMainMenu" />
                }
            }
            else if (authorizedUser.IsSupervisor)
            {
                <partial name="SupervisorMainMenu" />
            }
            else if (authorizedUser.IsInterviewer)
            {
                <partial name="InterviewerMainMenu" />
            }
            else
            {
                <partial name="ObserverMainMenu" />
            }
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
